From ca518e1e809b46cc40f9d292e6ee7211efeec20c Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 1 Oct 2009 12:26:15 +0100 Subject: [PATCH] Fix memory leak in libxenstore python bindings Temporary tuple0 python object was not freed at the end of xspy_set_permissions() in case no error occurred. To reduce code duplication, this path reuses the cleanup code. Signed-off-by: Jiri Denemark --- tools/python/xen/lowlevel/xs/xs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/xs/xs.c index ad47a279a4..7f28aa291a 100644 --- a/tools/python/xen/lowlevel/xs/xs.c +++ b/tools/python/xen/lowlevel/xs/xs.c @@ -324,6 +324,7 @@ static PyObject *xspy_set_permissions(XsHandle *self, PyObject *args) xs_transaction_t th; char *thstr; + PyObject *ret = NULL; if (!xh) goto exit; @@ -380,14 +381,13 @@ static PyObject *xspy_set_permissions(XsHandle *self, PyObject *args) goto exit; } - free(xsperms); Py_INCREF(Py_None); - return Py_None; + ret = Py_None; exit: Py_XDECREF(tuple0); free(xsperms); - return NULL; + return ret; } #define xspy_watch_doc "\n" \ -- 2.30.2